/// Copyright (c) Microsoft Corporation.  All rights reserved.

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization;
using System.Security.Permissions;

namespace Microsoft.VSPowerToys.Common.TaskManager.ContentInstaller
{
    /// <summary>
    /// Exception raised for errors during VSI related operations
    /// </summary>
    [Serializable]
    public class VsiException : Exception
    {

        private BaseVSContent content;

        public BaseVSContent Content
        {
            get
            {
                return content;
            }
        }

        /// <summary>
        /// Default required constructor to implement the ISerializable interface
        /// </summary>
        public VsiException()
            : base()
        {
        }

        /// <summary>
        /// Required constructor to implement the ISerializable interface
        /// </summary>
        public VsiException(string message)
            : base(message)
        {
        }

        /// <summary>
        /// Required constructor to implement the ISerializable interface
        /// </summary>
        public VsiException(string message, Exception exception)
            : base(message, exception)
        {
        }

        /// <summary>
        /// Constructor to initialize the task data of the exception
        /// </summary>
        public VsiException(BaseVSContent content)
        {
            this.content = content;
        }

        /// <summary>
        /// Constructor to initialize the task data of the exception, along with the message string
        /// </summary>
        public VsiException(string message, BaseVSContent content)
            : base(message)
        {
            this.content = content;
        }

        /// <summary>
        /// Constructor to initialize the task data of the exception, along with the message string, and an inner exception
        /// </summary>
        public VsiException(string message, Exception inner, BaseVSContent content)
            : base(message, inner)
        {
            this.content = content;
        }

        protected VsiException(
          System.Runtime.Serialization.SerializationInfo info,
          System.Runtime.Serialization.StreamingContext context)
            : base(info, context) { }

        /// <summary>
        /// Method required to properly implement ISerializable, we don't really have anything to do here.
        /// </summary>
        [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.SerializationFormatter)]
        public override void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            base.GetObjectData(info, context);
        }
    }
}
